﻿$(document).ready(function ()
{
    //UE.getEditor('content');

    $(".standardForm").ajaxForm(
        {
            url: "/Actions/Topic.ashx",
            dataType: 'json',
            beforeSubmit: function ()
            {
                $(".primary").attr("disabled", "disabled");
                return true;
            },
            success: function (data)
            {
                $(".primary").removeAttr("disabled");
                if (data.status)
                {
                    $('.PublishForm').window('close');
                    Message_Mini("success", data.message, 3);
                }
                else
                {
                    alert(data.message);
                }

            }
        });

    $(".cancelButton").click(function ()
    {
        $('.PublishForm').window('close');
    });
    $("#tags").keyup(publishFormButtonSet);
    $("#linkUrl").keyup(publishFormButtonSet);
    $("#content").keyup(submitkey);
    function submitkey(event)
    {
        publishFormButtonSet();
        if (event.keyCode == 13)
        {
            $(".standardForm").submit();
        }
    }

});

function publishFormButtonSet()
{
    var tags = $('#tags').val();
    //var linkUrl = $('#linkUrl').val();
    var content = $('#content').val();
    if (tags && content)
    {
        $(".primary").removeAttr("disabled");
    }
    else
    {
        $(".primary").attr("disabled", "disabled");
    }
}